package com.dylan.datacollection.utils;

import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;



/**
 * Created by dylan on 2016/7/26 0026.
 */
public class ToastUtils {
    public static void showShortMsg(Context context, String msg){
        Toast.makeText(context,msg, Toast.LENGTH_SHORT).show();
    }
    public static void showNetError(Context context,int status){
        switch (status){
            case 404:
                showShortMsg(context,"服务器找不到了！");
                break;
            case 500:
                showShortMsg(context,"服务器出错了！");
                break;
            default:
               showShortMsg(context,"网络异常，请检查网络环境！"+status);
                break;
        }
    }
    public static void showLongMsg(Context context,String msg){
        Toast toast = Toast.makeText(context,msg, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

}
